<template>
  <div>
    <!-- hello--{{val}}
    <button @click="fn">点击</button> -->

    <h1>
      <slot></slot>
    </h1>
    <h2>
      <slot name="h2" :nm="name2"></slot>
    </h2>
    <h3>
      <slot name="h3" :nm="name3"></slot>
    </h3>
  </div>
</template>

<script>
export default {
  // props: ["val"],
  props:{
    val: {
      validator: function(value){
        return ["1","2","3"].indexOf(value) != -1
      },
      // type: [String,Number,Object],
      // required: true,
      // default: "默认值",
      // default: function(){
      //   return {a:1}      // 复杂类型需要同个函数return
      // }
    }
  },
  data(){
    return {
      name2: '小红',
      name3: '小懒'
    }
  },
  beforeDestroy(){
    // console.log("beforeDestroy")
  },
  destroyed(){
    // console.log("destroyed")
  },
  methods: {
    fn(){
      console.log(this.val)
    }
  }
}
</script>

<style scoped>

</style>